/**@file   dma.c
 * @brief
 * 
 * @author SealedGhost
 */

#include "dma.h"
#include "misc.h"



void configDma1FromPeriphToMemory(DMA_Channel_TypeDef* channel, uint32_t src, uint32_t dest, size_t size)
{
	DMA_InitTypeDef config;
	
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	
	config.DMA_PeripheralBaseAddr    = src;
	config.DMA_MemoryBaseAddr        = dest;
	config.DMA_DIR                   = DMA_DIR_PeripheralSRC;
	config.DMA_BufferSize            = size;
	config.DMA_PeripheralInc         = DMA_PeripheralInc_Disable;
	config.DMA_MemoryInc             = DMA_MemoryInc_Enable;
	config.DMA_PeripheralDataSize    = DMA_PeripheralDataSize_Byte;
	config.DMA_MemoryDataSize        = DMA_MemoryDataSize_Byte;
	config.DMA_Mode                  = DMA_Mode_Normal;
	config.DMA_Priority              = DMA_Priority_VeryHigh;
	config.DMA_M2M                   = DMA_M2M_Disable;
	DMA_Init(channel, &config);
	
	DMA_Cmd(channel, ENABLE);
}

